home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / os2 / os2cl015.zip / pmsys.h < prev    next >
C/C++ Source or Header  |  1995-11-24  |  5KB  |  179 lines

  1. /* 
  2.  
  3.  
  4.     pmsys.h (emx+gcc) 
  5.  
  6.     1995 Giovanni Iachello
  7.     This is freeware software. You can use or modify it as you wish,
  8.     provided that the part of code that I wrote remains freeware.
  9.     Freeware means that the source code must be available on request 
  10.     to anyone.
  11.     You must also include this notice in all files derived from this
  12.     file.
  13.  
  14.  
  15. */
  16. #ifndef _PMSYS_H_
  17. #define _PMSYS_H_
  18.  
  19. #define INCL_DOSPROCESS
  20. #include <os2.h>
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23.  
  24. class PMMessageQueue;
  25.  
  26.  
  27. class PMAnchorBlock {
  28. protected:
  29.     HAB hab;
  30. public:
  31.     PMAnchorBlock();
  32.     PMAnchorBlock(HAB ab) { hab=ab; }
  33.     virtual ~PMAnchorBlock();
  34.     virtual void init(int flags=0);
  35.     virtual void uninit(void);
  36.     operator HAB () { return hab; }
  37.  
  38.     MRESULT dispachMsg(PQMSG pqmsg) {
  39.         return WinDispatchMsg (hab, pqmsg);
  40.     }
  41.     BOOL getMsg(PQMSG pqmsg, HWND hwndFilter=0L, ULONG msgFilterFirst=0, ULONG msgFilterLast=0) {
  42.         return WinGetMsg (hab,pqmsg,hwndFilter,msgFilterFirst,msgFilterLast);
  43.     }
  44.     BOOL peekMsg(PQMSG pqmsg, HWND hwndFilter=0L, ULONG msgFilterFirst=0, ULONG msgFilterLast=0, ULONG fl=0) {
  45.         return WinPeekMsg (hab,pqmsg,hwndFilter,msgFilterFirst,msgFilterLast,fl);
  46.     }
  47.  
  48.     POINTL msgPos() { 
  49.         POINTL point;
  50.         WinQueryMsgPos(hab,&point);
  51.         return point;
  52.     }
  53.     ULONG msgTime() {
  54.         return WinQueryMsgTime(hab);
  55.     }
  56.  
  57.     LONG loadMessage(ULONG id,LONG cchMax,PSZ pchBuffer,HMODULE hmod=NULLHANDLE)
  58.         { return WinLoadMessage(hab,hmod,id,cchMax,pchBuffer); }
  59.     LONG loadString(ULONG id,LONG cchMax,PSZ pchBuffer,HMODULE hmod=NULLHANDLE)
  60.         { return WinLoadString(hab,hmod,id,cchMax,pchBuffer); }
  61.     BOOL intersectRect(PRECTL prclDst, RECTL *prclSrc1, RECTL *prclSrc2) 
  62.         { return WinIntersectRect (hab,prclDst,prclSrc1,prclSrc2); }
  63.     BOOL ptInRect(RECTL *prcl, POINTL *pptl)
  64.         { return WinPtInRect (hab,prcl,pptl); }
  65.     BOOL unionRect(PRECTL prclDst,RECTL *prclSrc1, RECTL *prclSrc2)
  66.         { return WinUnionRect (hab,prclDst,prclSrc1,prclSrc2); }
  67.  
  68.     BOOL releaseHook (HMQ hmq, LONG iHook, PFN pfnHook, HMODULE hmod)
  69.         { return WinReleaseHook (hab, hmq, iHook, pfnHook, hmod); }
  70.     BOOL setHook (HMQ hmq, LONG iHook, PFN pfnHook, HMODULE hmod) 
  71.         { return WinSetHook (hab, hmq, iHook, pfnHook, hmod); }
  72.     
  73. };
  74.  
  75. class PMMessageQueue {
  76. protected:
  77.     HMQ hmq;
  78. public:
  79.     PMMessageQueue();
  80.     operator HMQ () { return hmq; }
  81.     void create(PMAnchorBlock ab) 
  82.         { hmq = WinCreateMsgQueue (ab, 0); }
  83.     BOOL destroy(void) 
  84.         { return WinDestroyMsgQueue(hmq); }
  85. };
  86.  
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89.  
  90. class PMApp {
  91.     int argc;       // conserva anche argomenti
  92.     char** argv;   // della linea di comando
  93.     PMAnchorBlock ab;
  94.     PMMessageQueue mq;
  95. public:
  96.     PMApp(PMAnchorBlock iab,PMMessageQueue imq,int iargc=0,char** iargv=NULL);
  97.     virtual void quit(int ret=0);    
  98.     virtual void run(void);
  99. };
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102.  
  103. class PMIniProfile {
  104.     HINI hini;
  105. public:
  106.     PMIniProfile(HAB ab,PCSZ filename) {
  107.         hini=PrfOpenProfile(ab,filename);
  108.     }
  109.     PMIniProfile(HINI ihini) {
  110.         hini=ihini;
  111.     }
  112.     ~PMIniProfile()    {
  113.         PrfCloseProfile(hini);
  114.     }
  115.     LONG queryInt(PCSZ pszApp, PCSZ pszKey, LONG sDefault) {
  116.         return PrfQueryProfileInt (hini,pszApp, pszKey, sDefault);}
  117.     BOOL queryProfile(HAB ab,PPRFPROFILE pPrfProfile) {
  118.         return PrfQueryProfile (ab,pPrfProfile);}
  119.     BOOL queryData (PCSZ pszApp, PCSZ pszKey, PVOID pBuffer, PULONG pulBufferLength) {
  120.         return PrfQueryProfileData (hini, pszApp, pszKey, pBuffer, pulBufferLength); }
  121.     BOOL querySize (PCSZ pszApp, PCSZ pszKey, PULONG pulReqLen) {
  122.         return PrfQueryProfileSize (hini, pszApp, pszKey, pulReqLen); }
  123.     ULONG queryString (PCSZ pszApp, PCSZ pszKey,PCSZ pszDefault, PVOID pBuffer, ULONG ulBufferLength)    {    
  124.         return PrfQueryProfileString (hini, pszApp, pszKey,pszDefault, pBuffer, ulBufferLength);    }
  125.     BOOL reset (HAB ab,PRFPROFILE *pPrfProfile) {
  126.         return PrfReset (ab,pPrfProfile); }
  127.     BOOL writeData (PCSZ pszApp, PCSZ pszKey, CPVOID pData, ULONG ulDataLength) {
  128.         return PrfWriteProfileData (hini, pszApp, pszKey, pData, ulDataLength); }
  129.     BOOL writeString (PCSZ pszApp, PCSZ pszKey, PCSZ pszData) {
  130.         return PrfWriteProfileString ( hini, pszApp, pszKey, pszData); }
  131. };
  132.  
  133. /////////////////////////////////////////////////////////////////////////////
  134.  
  135. class PMThread {
  136. protected:
  137.     void* arg;
  138.     int stacksize;
  139.     unsigned long id;
  140. public:
  141.     PMThread(void* iarg=NULL,int istacksize=8192);
  142.     virtual ~PMThread();
  143.     virtual void main(void* arg=NULL);
  144.     friend void threadstart(void* arg);
  145.  
  146.     unsigned long ID() { return id; }
  147.     unsigned failed() { return id==-1; }
  148.  
  149.     void threadStore(void *p);
  150.     void* threadStore();
  151.     ULONG kill() {
  152.         return DosKillThread (id);
  153.     }
  154.     ULONG resume() {
  155.         return DosResumeThread (id);
  156.     }
  157.     ULONG setPriority(ULONG ulScope, ULONG ulClass, LONG lDelta) {
  158.         return DosSetPriority (ulScope,ulClass,lDelta,id);
  159.     }        
  160.     ULONG suspend() {
  161.         return DosSuspendThread (id);
  162.     }
  163.     ULONG wait(ULONG ulWait) {
  164.         return DosWaitThread (&id, ulWait);
  165.     }
  166. };
  167.  
  168. class PMWindowThread : public PMThread, public PMAnchorBlock {
  169. protected:
  170.     int flags;
  171. public:
  172.     PMWindowThread(void* iarg=NULL,int istacksize=32768,int iflags=0);
  173.     ~PMWindowThread();
  174.     void main(void* arg=NULL);
  175. };
  176.  
  177. #endif
  178.  
  179.